home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 19 / macformat_19.iso / Shareware / Developers / N Game Library1.1.0E(ppc) / Font Sample(PPC) / Font_Sample(PPC).c < prev   
C/C++ Source or Header  |  1996-06-23  |  2KB  |  95 lines

  1. /*============================================================
  2.  
  3.                     N_Font sample program
  4.                     
  5. ============================================================*/
  6.  
  7. #include            "N_Library.h"
  8.  
  9. void             DoEvent            (EventRecord *eventPtr);
  10. void             DoError            (Str255 errorString);
  11. WindowPtr     CreateWindow         (Str255 name);
  12.  
  13. #define        WindowSizeX        640
  14. #define        WindowSizeY        480
  15.  
  16. short        NewWindowX;
  17. short        NewWindowY;
  18.  
  19. short        Data_Rsrc = 0;
  20.  
  21. WindowPtr    window;
  22.  
  23.  
  24. //counter
  25. long            counter1 = 123456;
  26. long            counter2 = 99999;
  27.  
  28. short        x = -100;
  29. short        x2 = 640;
  30.  
  31. void main(void)
  32. {
  33.     ToolboxInit();
  34.     ColorCheck();
  35.     HideCursor();
  36.     window = CreateWindow("\pN Game Library <Font Sample>");
  37.     N_Window_Set(window,NewWindowX,NewWindowY,WindowSizeX,WindowSizeY);    //set up window
  38.     Open_Resource_File(128,1,&Data_Rsrc);
  39.     N_Sp_Make(640,480);                                                //set up for sprites
  40.     N_Cel_Make(65536);                                                //set up for cel
  41.     N_Font_Init();
  42.     N_Sprite_Set(129,0,14,24,1,11,1,0);                                    //set sprites
  43.     N_Sprite_Set(130,11,12,16,1,13,4,0);
  44.  
  45.     N_Font_Set(0,0,0,0x80000000,0);                                        //set fonts
  46.     N_Font_Set(1,0x80000000+11,0,0x80000000+26+11,0x80000000+37+11);
  47.  
  48.     N_Pict_Draw(128,0,0,(GrafPtr)SP_off,true);                                //draw background
  49.     Close_Resource_File(&Data_Rsrc);
  50.  
  51.     do
  52.     {
  53.         N_Num_Put(counter1,x,80,8,16,0,1,0);                                    //(x,80)ÅAspace16,8segments,fontset0,cel plane  0-
  54.         N_Num_Put(counter2,x,138,8,14,1,1,24);                                //(x,160)ÅAspace14,8segments,fontset1,cel plane  24-
  55.         N_Font_Put("\pN GAME LIBRARY SAMPLE PROGRAM!",x2,180,14,1,1,30);
  56.         counter1++;                                                        //updates counters
  57.         counter2-=64;
  58.         if (counter1 >= 99999999) counter1 = 0;
  59.         if (counter2 <= 0) counter2 = 99999;
  60.     
  61.         x = x+1;                                                            //move
  62.         if (x >= 640) x=-100;
  63.  
  64.         x2-=2;
  65.         if (x2 <= -500) x2=640;
  66.  
  67.     
  68.         N_Cel_Loop(0,0);
  69.     }
  70.     while (!Button());
  71.     ShowCursor();
  72.     ColorRevert();
  73. }
  74.  
  75.  
  76. WindowPtr CreateWindow (Str255 name)
  77. {
  78.     short        centerX,centerY;
  79.     short        windowWidth,windowHeight;
  80.  
  81.     window = GetNewWindow (128,nil,(WindowPtr)-1L );
  82.     centerX  = (qd.screenBits.bounds.right -qd.screenBits.bounds.left)/2;
  83.     centerY  = (qd.screenBits.bounds.bottom -qd.screenBits.bounds.top)/2;
  84.     SetWTitle(window,name);
  85.     MoveWindow(window,NewWindowX=centerX-(WindowSizeX/2),NewWindowY=centerY-(WindowSizeY/2),false);
  86.     SizeWindow(window,WindowSizeX,WindowSizeY,TRUE);
  87.     ShowWindow(window);
  88.     SetPort((GrafPtr)window );
  89.     return (WindowPtr)window;
  90. }
  91.     
  92.  
  93.  
  94.  
  95.